#include <gtest/gtest.h>
#include "calculator.h"

// 基础测试：直接使用 TEST 宏
TEST(CalculatorTest, AddPositiveNumbers) {
    EXPECT_EQ(add(2, 3), 5);
    EXPECT_EQ(add(0, 0), 0);
    EXPECT_EQ(add(-1, 1), 0);
}

TEST(CalculatorTest, SubtractPositiveNumbers) {
    EXPECT_EQ(subtract(5, 3), 2);
    EXPECT_EQ(subtract(0, 0), 0);
    EXPECT_EQ(subtract(3, 5), -2);
}

// 使用测试夹具（Test Fixture）提高可扩展性
class CalculatorFixture : public ::testing::Test {
protected:
    void SetUp() override {
        // 可在此初始化共享资源
    }

    void TearDown() override {
        // 可在此清理资源
    }
};

TEST_F(CalculatorFixture, AddNegativeNumbers) {
    EXPECT_EQ(add(-2, -3), -5);
}

TEST_F(CalculatorFixture, SubtractNegativeNumbers) {
    EXPECT_EQ(subtract(-5, -3), -2);
}
